﻿using Core.DataAccess.ApiJson;
using iTool.ClusterComponent;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Grain.Interfaces
{
    /// <summary>
    /// 数据库配置管理部分
    /// </summary>
    public interface IDatabaseConfigurationService : iToolService
    {
        /// <summary>
        /// 新增数据库
        /// </summary>
        /// <param name="title">名称</param>
        /// <param name="connaction">连接地址</param>
        /// <returns></returns>
        Task Register(string title, string connaction);

        /// <summary>
        /// 删除数据库
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        Task Remove(string title);

        /// <summary>
        /// 修改数据库
        /// </summary>
        /// <param name="title"></param>
        /// <param name="connaction"></param>
        /// <returns></returns>
        Task Modify(string title, string connaction, Dictionary<string, TableSchema> schema = null);

        /// <summary>
        /// 获取数据库列表
        /// </summary>
        /// <returns></returns>
        Task<Dictionary<string, string>> GetConnactionList();

        /// <summary>
        /// 获取指定数据库
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        Task<(string connationString, string schema)> GetConnactionByTitle(string title, bool isReadSchema = false);
    }
}
